<?php
/**
 * 权限
 */
namespace app\model;

use think\Model;
use app\libs\Predis;

class CompanylabelModel extends Model
{
	// 设置当前模型对应的完整数据表名称
	protected $name = 'labels';
	
	// 设置字段信息
	protected $schema111 = [
			'id'          => 'int',
			'label'        => 'string',
	];
	
	// 设置当前模型的数据库连接
	protected $connection ='db_yunduan';
	
	/**
	 * 递归
	 */
	public function GetInfo($id=0){
		
		$cache = new Predis();
		$data=$cache->get('CompanylabelDiGui_'.$id);
		if($data){
			$result=unserialize($data);
		}else{
			$Companylabel = new CompanylabelModel();
			$result=$Companylabel->field('id,label')->where(['status'=>1])->order('sorts desc')->select()->toArray();
			
			//$result=arr2tree($res,$id,'label','id');
			$cache->set('CompanylabelDiGui_'.$id,serialize($result),3600);
		}
		return $result;
	}
	
	
}
